let arr = [1, 2, -3, -4]
const result1 = arr.find(item => item < 0)
const result2 = arr.findIndex(item => item < 0)
console.log('result1', result1) // -3
console.log('result2', result2) // 2

// 处理NaN
let arr_ = ['a', NaN]
const result3 = arr_.find(item => Number.isNaN(item))
const result4 = arr_.findIndex(item => Number.isNaN(item))
console.log('result3', result3) // NaN
console.log('result4', result4) // 1

// from方法 用于将类数组对象转化为array
const arrLike = {
  0: 'a',
  1: 'b',
  2: 'c',
  length: 3
}
console.log(Array.from(arrLike)) // ['a', 'b', 'c']

// fill()方法   用爱初始化一个修年间的array对象
console.log(new Array(5).fill('a')) // [ 'a', 'a', 'a', 'a', 'a' ]

// 数组的遍历方法

const a = ['a', 'b', 'c']
for (let i of a.keys()) {
  console.log('keys()', i)
}

for (let i of a.values()) {
  console.log('values', i)
}

for (let i of a.entries()) {
  console.log('entries', i)
}



